import { RouteRecordRaw } from "vue-router"
import { MutationTree } from "vuex"

import { PermissionConstant } from "./constant"
import { PermissionState } from "./state"
import { routes as constantRoutes } from "@/router"



export type Mutations<S = PermissionState> = {
  [PermissionConstant.MUTATION_SET_ROUTES](state: S,routes: RouteRecordRaw[]):void
}

export const mutations:Mutations & MutationTree<PermissionState> = {
  [PermissionConstant.MUTATION_SET_ROUTES](state:PermissionState,routes: RouteRecordRaw[]){
    state.routes = constantRoutes
    state.dynamicRoutes = routes
  }
}